package springcloud.consume.feign.hystrix;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import springcloud.consume.feign.service.UserService;
import springcloud.service.model.User;

import java.util.ArrayList;
import java.util.List;

@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {


    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public User getUserById(Integer userId) {
                User user = new User();
                user.setUserAddress("服务器熔断方法处理的，地址哈哈哈");
                user.setUserPhone("111111111111111");
                return user;
            }

            @Override
            public int addUser(User user) {
                return 0;
            }

            @Override
            public List<User> getAll() {
                return new ArrayList<>();
            }
        };
    }
}
